package com.example.demo.controller;

import com.example.demo.pojo.HellLog;
import com.example.demo.pojo.Lifebook;
import com.example.demo.pojo.PageResult;
import com.example.demo.pojo.Result;
import com.example.demo.service.Impl.HellLogServiceImpl;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/")
public class HellLogController {
    @Autowired
    private HellLogServiceImpl hellLogService;
    //地狱受刑添加
    @PostMapping("/hellrecordadd")
    public Result HellLogAdd(@RequestBody HellLog hellLog){
        String s = hellLogService.HellLogAdd(hellLog);
        if (s.equals("添加成功")){
            return Result.success(s);
        }
        return Result.error(s);
    }
    //地狱受刑列表查询
    @GetMapping("/hellrecordlist")
    public Result HellLogQuery(@RequestParam(defaultValue = "1") Integer page,
                               @RequestParam(defaultValue = "10") Integer limit,
                               HellLog hellLog){
        PageInfo list = hellLogService.HellLogQuery(page, limit, hellLog);
        return PageResult.success03(list.getList(), (int) list.getTotal());
    }
    //地狱受刑删除
    @DeleteMapping("/hellrecorddel")
    public Result HellLogDelete(Integer id){
        hellLogService.HellLogDelete(id);
        return Result.success("删除成功");
    }
    //地狱受刑修改
    @PutMapping("/hellrecordedit")
    public Result HellLogUpdate(@RequestBody HellLog hellLog){
        hellLogService.HellLogUpdate(hellLog);
        return Result.success("修改成功");
    }
}
